const db = require('./db/db')

db(() => {
  const express = require('express')
  const bodyParser = require('body-parser')
  const bookRouter = require('./routes/book')

  const app = express()

  app.use(bodyParser.json()) // 解析JSON数据
  app.use(bodyParser.urlencoded({ extended: true })) // 解析URL编码数据
  app.use(bookRouter)

  app.listen(3000, () => {
    console.log('服务已启动，3000端口监听中。。。')
  })
}, error => {
  console.log('数据库连接异常', error)
})